<template>
	<el-dialog
     :visible.sync="editPriceDateShow"
		  title="设置价格日历"
		  width="80%"
		  style="margin-left: 100px;"
		>
		<div class="carMywrapper">
			<div class="type-radio">
				<el-calendar>
					<!-- 这里使用的是 2.5 slot 语法，对于新项目请使用 2.6 slot 语法-->
					<template
					slot="dateCell"
					slot-scope="{date, data}">
					<div >
						<div>
							<div>
							{{data.day.split('-').slice(1).join('-')}} 
							</div>
							<div  class="display-flex" style=" position: relative;" v-if="item.date == data.day"  v-for="(item, index) in tempAttr.dateList" :key="index">
								<div class="mt-20">
									<div style="color: #1f37f1;">售价：￥{{item.price}}</div>
									<!-- <div>原价：{{item.ot_price}}</div> -->
									<div :style="item.stock<10?'color: #ff0000;':'color: #1f37f1;'">库存：{{item.stock}}</div>
								</div>
								<div v-if="data.isSelected" @click="changePrice(item,index)" style="margin-top: -15px;right: 0px;position: absolute;">
									<i class="el-icon-edit-outline ml-10 text-20" ></i>
								</div>
							</div>
						</div>
						
					</div>	
					</template>
				</el-calendar>
			</div>
	    </div>


		<el-dialog
			v-if="dialogVisible"
			title="修改价格/库存"
			:visible.sync="dialogVisible"
			width="500px"
			append-to-body
		>
			<div class="container">
				<el-form label-width="80px" size="small">
					<el-form-item  label="售价：">
						<el-input v-model="priceItem.price" type="number" placeholder="请输入售价" class="selWidth" size="small"  /> 
					</el-form-item>
					<el-form-item label="库存：">
						<el-input v-model="priceItem.stock"  type="number" placeholder="请输入库存" class="selWidth" size="small"  /> 
					</el-form-item>
				</el-form>
				
			</div> 
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false" size="small">取消</el-button>
				<el-button type="primary" @click="handleCancellation" size="small">确定修改</el-button>
			</span>    
		</el-dialog> 
	
	</el-dialog>
</template>
<script>

	import SettingMer from "@/libs/settingMer";
	import { getToken } from "@/utils/auth";
	import exportExcel from "@/utils/newToExcel.js";
	import {
	  importCard,
	  exportProductCard
	} from "@/api/product";
import { forEach } from "jszip/lib/object";
    export default {
			name: "editPriceDate",
			props:{

				tempAttr: {
					type: Object,
					default: function () {
						return {};
					}
				},
			
				svip_price_type: {
					type: Number,
					default: function () {
						return 0;
					}
				},
				extension_type: {
					type: Number,
					default: function () {
						return 0;
					}
				},
            },
			data(){
				return {
					editPriceDateShow: false,
					dialogVisible: false,
					priceItem: {},
					priceIndex: '',
				}
			},
			computed: {
				// cardUrl() {
				// 	return (
				// 		SettingMer.https +
				// 		`/upload/image/file`
				// 	);
				// }
			},
			created() {
			
			},
			mounted() {
				console.log('tempAttr',this.tempAttr)
			},
      methods:{
		changePrice(item,index){
			console.log(123,item);
			this.priceItem = item;
			this.priceIndex = index;
			this.dialogVisible = true
		},
		handleCancellation(){
			if(!this.priceItem.price){
				return this.$message.error("请输入价格")
			}
			if(!this.priceItem.stock){
				return this.$message.error("请输入库存")
			}
			this.tempAttr.dateList[this.priceIndex] = this.priceItem;
			this.dialogVisible = false;
		},		
		subBtn(){
			
			this.editPriceDateShow = false;
	
			
		},
		cancel(){
			
			this.editPriceDateShow = false;
		}
      }
    }
</script>

<style lang="scss" scoped>
	.width15{
		width: 150px;
	}
	::v-deep .el-radio__label{
		font-size: 13px;
	}
	.carMywrapper{
		.download{
			margin-left: 10px;
		}
		.stock-disk{
			margin: 10px 0 15px 0;
		}
		.scroll-virtual {
		  max-height: 320px;
		  overflow-y: auto;
		  margin-top: 10px;
		}
		.virtual-title {
		  width: 50px;
		}
		.deteal-btn {
		  color: #5179ea;
		  cursor: pointer;
		}
		.add-more {
		  margin-top: 20px;
			line-height: 32px;

		}
		.footer{
			display: flex;
			justify-content: flex-end;
			margin-top: 40px;
			button{
				margin-left: 10px;
			}
		}
	}
	::v-deep .el-input-group--append .el-input__inner{
		padding-right: 0;
	}
</style>
